/*!
 * \file frtime2str.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "frstr.h"
#include "conntrack.h"
#include "frct_comm.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

static void __case1(void)
{
    int i_ret = 0;
    struct timeval st_tv;
    char *p_time = NULL;
    unsigned int ui_time_size = 50;

    p_time = (char *)frmalloc(ui_time_size);
    if(!p_time)
        return;

    st_tv.tv_sec = 0;
    st_tv.tv_usec = 0;

    i_ret = frtime2str(&st_tv , p_time, ui_time_size);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);
    CU_ASSERT_STRING_EQUAL(p_time,(char *)"1970/01/01 08:00:00.000000");

    frfree(p_time);
    return;
}

static void __case2(void)
{
    int i_ret = 0;
    struct timeval st_tv;
    char *p_time = NULL;
    unsigned int ui_time_size = 0;

    st_tv.tv_sec = 0;
    st_tv.tv_usec = 0;

    i_ret = frtime2str(&st_tv , p_time, ui_time_size);

    CU_ASSERT_EQUAL(i_ret,FR_FAIL);
    CU_ASSERT_PTR_NULL(p_time);

    return;
}

int add_suite_frtime2str(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frsutl frtime2str()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);

    return FR_SUCC;
}
